/**
 * 
 */
package com.feonix.nio.test.scatterandgatter;

import java.io.File;
import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @CopyRight (c)1993-2017
 * @Project common_practice
 * @Comments 请输入该类的描述
 * @NameSpace com.feonix.nio.test.scatterandgatter
 * @Author Feonixzw
 * @CreateDate 2018年3月12日
 */
public class ScattingAndGather {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}
	
	public static void gather(){
		ByteBuffer bf1 = ByteBuffer.allocate(10);
		ByteBuffer bf2 = ByteBuffer.allocate(10);
		byte[] byte1 = {'1', '2'};
		byte[] byte2 = {'3', '4'};
		bf1.put(byte1);
		bf2.put(byte2);
		ByteBuffer[] bf3 = {bf1, bf2};
		try{
			FileOutputStream fos = new FileOutputStream("src/main/java/com/feonix/nio/test/nio.txt");
			FileChannel fc = fos.getChannel();
			fc.write(bf3);
			fc.close();
			fos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			
		}
		
	}

}
